<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-yellow sidebar-mini">
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel" align="center">
                    修改发货计划主单
                </h4>
            </div>
            <div class="modal-body">
                <form id="partForm" class="form-horizontal" role="form">
                    <input type="hidden" id="id" name="id">
                    <input type="hidden" id="comit" name="comit">
                    <input type="hidden" id="createTime" name="createTime">
                    <input type="hidden" id="createName" name="createName">

                    <div class="form-group" id="DD">
                        <label class="col-sm-3 control-label no-padding-right">项目编号 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="proCode" id="sheetForm-proCode" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">项目名称 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="proName" id="sheetForm-proName" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">需方 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="customer" id="sheetForm-customer" readonly>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">发货地址 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="address" id="sheetForm-address">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">负责人 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="leader"
                                   id="sheetForm-leader">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right">接收人 ：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="relMan"
                                   id="sheetForm-relMan">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">计划发货时间 :</label>
                        <div class="col-md-9">
                            <input type="text" class="form-control datepicker" name="planTime"
                                   readonly="readonly" style="width: 100%;"/>
                        </div>
                    </div>
                    <input type="hidden" class="form-control" name="proId" id="proId">
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary" onclick="saveMaintain()" id="btn-add">
                    提交
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<section class="content-header">
    <h1>发货计划查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">生产令号</label>
                                    <input id="query-proCode" type="text" name="proCode" class="form-control"
                                           placeholder="请输入生产令号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-address">发货地点</label>
                                    <input id="query-address" type="text" name="address" class="form-control"
                                           placeholder="请输入发货地点">
                                </div>
                                <div class="form-group">
                                    <label for="query-customer">需方</label>
                                    <input id="query-customer" type="text" name="customer" class="form-control"
                                           placeholder="请输入需方">
                                </div>
                                <div class="form-group">
                                    <label for="query-leader">负责人</label>
                                    <input id="query-leader" type="text" name="leader" class="form-control"
                                           placeholder="请输入负责人">
                                </div>
                                <div class="form-group">
                                    <label for="query-relMan">接收人</label>
                                    <input id="query-relMan" type="text" name="relMan" class="form-control"
                                           placeholder="请输入接收人">
                                </div>
                                <div class="form-group">
                                    <label for="query-comit">提交状态</label>
                                    <select id="query-comit" class="form-control" name="comit">
                                        <option value=""  selected="selected">全部</option>
                                        <option value="1">未提交</option>
                                        <option value="2">已提交</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-startTime">创建日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker"
                                           name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <input type="hidden" class="form-control" name="name" id="name">
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table, table1, table2;
    /**添加明细选择按钮*/
    /** 项目编号下拉框选中 */
    $("#sheetForm-proCode").on("select2:select", function () {
        $("#sheetForm-proName").val($(this).select2("data")[0].proName);
        $("#sheetForm-customer").val($(this).select2("data")[0].customer);
        $("#proId").val($(this).select2("data")[0].proId);
        $("#sheetForm-proCode").val($(this).select2("data")[0].proCode);
    });

    /**保存模态框*/
    function saveMaintain() {
        let res = js.vd({
            id: 'partForm',
            notEmpty: ['proCode', 'planTime', 'leader', 'relMan', 'address']
        })
        if (!res) {
            return;
        }
        var url = ctx + "create/shipmentsEdit/edit/PlanSheet";
        js.validSubmit({
            formId: "partForm",
            url: url,
            data: new FormData($("#partForm")[0]),
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    js.table.refresh(table);
                    js.modal.hide("myModal");
                } else {
                    js.modal.warning(result.msg);
                }
            }
        });

    }

    $(function () {
        /** 加载列表 */
        table = js.table.init({
            id: 'bootstrap-table',
            url: ctx + "create/shipmentsEdit/list",
            showExport: false,
            pageSize: 20,
            uniqueId: 'id',
            onClickRow: function (row, $element) {
                    $('.info').removeClass('info');
                    $($element).addClass('info');
            },
            columns: [
                {

                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "生产令号", field: 'proCode'},
                {title: "项目名称", field: 'proName'},
                {title: "需方", field: 'customer'},
                {title: "发货地点", field: 'address'},
                {title: "负责人", field: 'leader'},
                {title: "接收人", field: 'relMan'},
                {title: "计划发货时间", field: 'planTime'},
                {title: "创建人", field: 'createName'},
                {title: "创建日期", field: 'createTime'},
                {
                    title: "提交状态", field: 'comit',
                    formatter: function (value) {
                        if (value==1){
                            return '<span class="badge label-default">未提交</span>';
                        }
                        if (value==2){

                            return '<span class="badge label-success">已提交</span>';
                        }
                    }
                },
                {
                    title: "操作",
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs"  href="' +ctx + 'create/shipmentsEdit/listDetailSelect/' + row.id + '" > 查看</a>');

                        return actions.join('');
                    }
                }
            ]
        });

    });
    function edit(id) {

        var rowData = $('#bootstrap-table').bootstrapTable('getRowByUniqueId', id);//行的数据
        $("#partForm").fillSpan(rowData);
        $("#partForm").fillData(rowData);
        js.modal.open("myModal");
    }
    /** * 用户模态框 */
    function openReleaseModal() {
        document.getElementById("partForm").reset();
        js.modal.open("myModal");

    }
    /** 删除主单 */
    function delMain(id) {
        js.modal.confirm("确定要删除发货单吗？", function () {
            js.post({
                url: ctx + "create/shipmentsEdit/delMain",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }
    /** 提交 */
    function comit(id) {
        js.modal.confirm("确定要提交发货单吗？", function () {
            js.post({
                url: ctx + "create/shipmentsEdit/comit",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }
    /** 撤销 */
    function regit(id) {
        js.modal.confirm("确定要撤销提交吗？", function () {
            js.post({
                url: ctx + "create/shipmentsEdit/regit",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }
</script>
</body>
</html>